/**
  logger.h - Created by Timothy Morey on 5/21/2012

  The logger provides a tool to write application log messages to a file and
  optionally print them to stdout at the same time.
*/

#ifndef __LOGGER_H
#define __LOGGER_H

#include "libnvn.h"

/**
  Enumerates the various types of log messages that may be written to a channel.
*/
typedef enum
{
  LogLevelMute  = 0x0,  // Indicates that no messages should be written.

  LogLevelDebug = 0x1,  // Debug messages are messy messages that may be
                        // helpful to the developer, but are not helpful in the
                        // normal execution of the program.

  LogLevelInfo  = 0x2,  // Info messages are messages that may be of interest
                        // to any user, and provide information about the
                        // internal state of the program.

  LogLevelError = 0x4   // Error messages indicate that something has gone
                        // wrong in the program.

} LogLevel;

/**
  Sets the log levels for the logger.

  @param fileLevel The types of messages that should be written to the logfile.
  @param stdoutLevel The types of messages that should be written to stdout.
  @param stderrLevel The types of messages that should be written to stderr.
  
  @return 1 if the operation is successful, and 0 if an error occurs.
*/
EXPORT int ChangeLogLevels(LogLevel fileLevel, LogLevel stdoutLevel, LogLevel stderrLevel);

/**
  Initializes the logger.  This should be called before any other logger 
  functions are called -- probably one of the first lines in main.

  @param filename The path to a file that will be used to store log messages.
  @param fileLevel The types of messages that should be written to the logfile.
  @param stdoutLevel The types of messages that should be written to stdout.
  @param stderrLevel The types of messages that should be written to stderr.
  
  @return 1 if the operation is successful, and 0 if an error occurs.
*/
EXPORT int InitLogger(const char* filename, 
                      LogLevel fileLevel, LogLevel stdoutLevel, LogLevel stderrLevel);

/**
  Writes a log message.

  @param level The type of message.
  @param msg The content of the message.
  
  @return 1 if the operation is successful, and 0 if an error occurs.
*/
EXPORT int WriteMessage(LogLevel level, const char* msg);

#endif
